package cn.hj.config;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class MyServlet extends HttpServlet implements WebInitializerInterface {
    @Override
    public void init(ServletContext sc) {
        ServletRegistration.Dynamic myservlet = sc.addServlet("myservlet", new MyServlet());
        myservlet.addMapping("/my");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String str=req.getServletContext().getAttribute("pp").toString();
        System.out.println("servlet....");
        resp.getWriter().write(str);
    }
}
